package com.esxy.service.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.esxy.dao.TbContentMapper;
import com.esxy.entity.TbContent;
import com.esxy.entity.TbContentExample;
import com.esxy.service.TbContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Service(interfaceClass = TbContentService.class)
public class TbContentServiceImpl implements TbContentService {

    @Autowired(required = false)
    private TbContentMapper tbContentMapper;

    @Override
    public List<TbContent> getContentAll(TbContentExample tbContentExample) {
         List<TbContent> i = tbContentMapper.selectByExample(tbContentExample);
         return i;
    }

    @Override
    public TbContent selectById(Long id) {
        TbContent i = tbContentMapper.selectByPrimaryKey(id);
        return i;
    }

    @Override
    public int addContent(TbContent tbContent){
        int i =tbContentMapper.insertSelective(tbContent);
        return i;
    }



    @Override
    public int deleteById(Long id) {
        int i = tbContentMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public int updateContent(TbContent tbContent) {
        int i = tbContentMapper.updateByPrimaryKey(tbContent);
    return i;
    }

    @Override
    public List<TbContent> getContentByStatus() {
        TbContentExample example = new TbContentExample();
        example.createCriteria().andStatusEqualTo(1);
        return tbContentMapper.selectByExample(example);
    }
}
